﻿<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 *
 */
class User extends MY_Controller {

	function Log(){
		parent::__construct();
		$this->load->model('M_user');
	}
	

    //修改密码
    function passw_save(){
        $PID = isset($_COOKIE['user_id']) ? DES_ADMIN::decrypt($_COOKIE['user_id']) : '';
            if(empty($PID)){
                //return $this->load->view('views_login.php');
            }
            $userinfo = $this->M_user->getRow('*',array('PID'=>$PID));
            if($_POST || $_GET){
                $yuan_pass = getParam($this->input->get_post("passWord"),'string');
                $newpass = getParam($this->input->get_post("newWord"),'string');
                $newPassword = getParam($this->input->get_post("newPassword"),'string');

                if($userinfo['Password'] != $yuan_pass){
                    exit(json_encode(array('code'=>1,'info'=>'原密码不对','data'=>array())));
                }
                if($newpass != $newPassword){
                    exit(json_encode(array('code'=>1,'info'=>'两次密码不一致','data'=>array())));
                }
            $this->M_user->updateData(array('Password'=>$newpass),array('PID'=>$PID));
            $_fromurl = isset($_SERVER["HTTP_REFERER"])?$_SERVER["HTTP_REFERER"]:'';
            $array = array('user_id' => '', 'user_name' => '','user_key'=>'' , 'action_time'=> '');
            ssetcookie($array, -1,'/',COOKIE_DOMAIN_PLAY);
            exit(json_encode(array('code'=>0,'info'=>'修改成功','data'=>array())));
        }
        $this->load->view('changePass.php',array('data'=>$userinfo));
    }
}
